package com.lxb.myforum.pojo

import java.util.Date

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.ManyToOne
import javax.persistence.Table
import javax.persistence.Temporal
import javax.persistence.TemporalType

/**
 * post 的回复
 * @author lxb
 */
@Entity
@Table(name = "t_reply")
data class Reply (
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @Column(name = "content")
    var content: String? = null,

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time")
    var createTime: Date? = null,

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time")
    var updateTime: Date? = null,

    @ManyToOne(targetEntity = User::class)
    @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
    var user: User? = null,

    @ManyToOne(targetEntity = Post::class)
    @JoinColumn(name = "post_id", referencedColumnName = "id", nullable = false)
    var post: Post? = null
)
